package com.xbts.screen.controller.workshop;

import com.xbts.common.core.web.controller.BaseController;
import com.xbts.common.core.web.domain.AjaxResult;
import com.xbts.common.core.web.domain.BaseHistogramResult;
import com.xbts.common.security.annotation.RequiresPermissions;
import com.xbts.screen.domain.workshop.vo.ProductionScheduleVO;
import com.xbts.screen.domain.workshop.vo.RealTimeAchievementRateVO;
import com.xbts.screen.domain.workshop.vo.StatisticalRateGroupByTimeVO;
import com.xbts.screen.service.ICuttingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 开料车间Controller
 */
@Api(tags = "开料车间")
@RestController
@RequestMapping("/cutting")
public class CuttingController extends BaseController {


    @Autowired
    private ICuttingService cuttingService;

    /**
     * 实时达成率
     */
    @ApiOperation("实时达成率")
    @RequiresPermissions("workshop:cutting:realTimeAchievementRate")
    @GetMapping("/realTimeAchievementRate")
    public AjaxResult realTimeAchievementRate(){
        RealTimeAchievementRateVO vo = cuttingService.realTimeAchievementRate();
        return success(vo);
    }
    /**
     * 近10天达成率
     */
    @ApiOperation("近10天达成率")
    @RequiresPermissions("workshop:cutting:tenDaysAchievementRate")
    @GetMapping("/tenDaysAchievementRate")
    public AjaxResult tenDaysAchievementRate(){
        BaseHistogramResult result = cuttingService.tenDaysAchievementRate();
        return success(result);
    }
    /**
     * 达成率根据时间分组
     */
    @ApiOperation("达成率根据时间分组")
    @RequiresPermissions("workshop:cutting:achievementRateGroupByTimeType")
    @GetMapping("/achievementRateGroupByTimeType")
    public AjaxResult achievementRateGroupByTimeType(){
        StatisticalRateGroupByTimeVO vo = cuttingService.achievementRateGroupByTimeType();
        return success(vo);
    }
    /**
     * 水单耗
     */
    @ApiOperation("水单耗")
    @RequiresPermissions("workshop:cutting:waterUnitConsume")
    @GetMapping("/waterUnitConsume")
    public AjaxResult waterUnitConsume(){
        BaseHistogramResult result = cuttingService.waterUnitConsume();
        return success(result);
    }
    /**
     * 电单耗
     */
    @ApiOperation("电单耗")
    @RequiresPermissions("workshop:cutting:electricityUnitConsume")
    @GetMapping("/electricityUnitConsume")
    public AjaxResult electricityUnitConsume(){
        BaseHistogramResult result = cuttingService.electricityUnitConsume();
        return success(result);
    }
    /**
     * 排产计划
     */
    @ApiOperation("排产计划")
    @RequiresPermissions("workshop:cutting:productionSchedule")
    @GetMapping("/productionSchedule")
    public AjaxResult productionSchedule(){
        List<ProductionScheduleVO> vos = cuttingService.productionSchedule();
        return success(vos);
    }
    /**
     * 周转率
     */
    @ApiOperation("周转率")
    @RequiresPermissions("workshop:cutting:turnoverRate")
    @GetMapping("/turnoverRate")
    public AjaxResult turnoverRate(){
        BaseHistogramResult vo = cuttingService.turnoverRate();
        return success(vo);
    }
    /**
     * 周转率根据时间类型分组
     */
    @ApiOperation("周转率根据时间类型分组")
    @RequiresPermissions("workshop:cutting:turnoverRateGroupByTimeType")
    @GetMapping("/turnoverRateGroupByTimeType")
    public AjaxResult turnoverRateGroupByTimeType(){
        StatisticalRateGroupByTimeVO vo = cuttingService.turnoverRateGroupByTimeType();
        return success(vo);
    }
}
